package node_login

import (
	"sanguo/cluster"
	ss_meg "sanguo/protocol/ss/message"
	"time"

	"github.com/golang/protobuf/proto"
)

func reportStatus() {
	//开启一个go程 向dir服上报状态
	go func() {
		for {
			time.Sleep(time.Second * 1)
			cluster.PostTask(func() {
				var playerNum int32 = 0
				for _, v := range gameMap {
					playerNum += v.playerNum
				}

				report := &ss_meg.ReportStatus{
					ServerId:   proto.Int32(int32(areaID_)),
					ServerAddr: proto.String(loginAddr),
					PlayerNum:  proto.Int32(int32(playerNum)),
				}

				//Infoln("ReportStatus", report)
				cluster.Brocast("dir", report)
			})
		}
	}()
}
